from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `attr` ADD `cid_id` INT   COMMENT '所属分类';
        ALTER TABLE `attr` ADD CONSTRAINT `fk_attr_category_4d8cb548` FOREIGN KEY (`cid_id`) REFERENCES `category` (`id`) ON DELETE CASCADE;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        ALTER TABLE `attr` DROP FOREIGN KEY `fk_attr_category_4d8cb548`;
        ALTER TABLE `attr` DROP COLUMN `cid_id`;"""
